<template>
  <div>
    <div class="addUser">
      <ul>
        <li>
          <label>用户名称：</label>
          <input type="text" placeholder="请输入用户名称" v-model="addUser.username" />
        </li>
        <li>
          <label>用户密码：</label>
          <input type="text" placeholder="请输入用户密码" v-model="addUser.password" />
        </li>
      </ul>
      <div class="buttons">
        <button style=" backgroundColor:skyblue;" @click="addUsersignOut">退出</button>
        <button style=" backgroundColor:yellow;" @click="addUserSubmit">提交</button>
      </div>
    </div>
  </div>
</template>


<script>
export default {
  name: "App",
  props: [],
  components: {},
  data() {
    return {
      addUser: {
        username:"",
        password:""
      }
    };
  },
  //方法 函数写这里
  methods: {
    addUsersignOut() {
      this.$router.push("/home/user");
    },
    async addUserSubmit() {
      var addUser1 =(
        this.addUser.username !== "" &&
        this.addUser.username !== "")
      if (!addUser1) {
        return;
      }
      const res = await this.$http.post("http://127.0.0.1:3003/addUser", {
        params: this.addUser
      });
      if(res.data.code==200){
        this.$router.push("/home/user");
      }
    }
  },
  //计算属性
  computed: {},
  //侦听器
  watch: {},
  //过滤器
  filters: {},
  //以下是生命周期
  //组件创建之前
  beforeCreate() {},
  //组件创建之后
  created() {},
  //页面渲染之前
  beforeMount() {},
  //页面渲染之后
  mounted() {},
  //页面视图数据更新之前
  beforeUpdate() {},
  //页面视图数据更新之后
  updated() {},
  //页面销毁之前
  beforeDestroy() {},
  //页面销毁之后
  destroyed() {}
};
</script>
<style lang="scss" scoped>
.addUser {
  width: 1000px;
  height: 600px;
  background-color: #fff;
  position: absolute;
  top: 50px;
  left: 200px;
  box-shadow: #ccc 0px 0px 40px;
}
.addUser ul {
  margin-top: 20px;
}

.addUser ul li {
  margin: 10px 0px;
}

.addUser ul li label {
  display: inline-block;
  font-size: 18px;
  font-weight: bold;
  width: 100px;
  height: 40px;
  margin: 0 20px;
  text-align: right;
}

.addUser ul li input {
  width: 500px;
  height: 26px;
}

.addUser .buttons {
  display: flex;
  width: 400px;
  font-size: 16px;
  justify-content: space-between;
  align-items: center;
  margin-left: 140px;
}
.addUser .buttons button {
  width: 80px;
  height: 30px;
}
</style>
